commands/test: Stack overflow due to unlimited recursion depth
authorLidong Chen <lidong.chen@oracle.com>
Mon, 16 Dec 2024 20:22:41 +0000 (20:22 +0000)
committerFelix Zielcke <fzielcke@z-51.de>
Thu, 3 Jul 2025 16:35:51 +0000 (18:35 +0200)
commitd99b8405d9853fcd72146549b1a15a15c3803614
tree760af0e93ecd030d8c8ac6d7567dda0097612a73
parentd94ed65f7d4fed4f719b1154eb17e5174c05245e
commands/test: Stack overflow due to unlimited recursion depth

The test_parse() evaluates test expression recursively. Due to lack of
recursion depth check a specially crafted expression may cause a stack
overflow. The recursion is only triggered by the parentheses usage and
it can be unlimited. However, sensible expressions are unlikely to
contain more than a few parentheses. So, this patch limits the recursion
depth to 100, which should be sufficient.

Reported-by: Nils Langius <nils@langius.de>
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name commands-test-Stack-overflow-due-to-unlimited-recursion-d.patch
grub-core/commands/test.c